
/**
 * @file filter.h
 * Audio filters header
 */

#ifndef FILTER_H
#define FILTER_H

#include "common.h"

enum FilterType {
    FILTER_TYPE_LOWPASS,
    FILTER_TYPE_HIGHPASS,
    FILTER_TYPE_BANDPASS,
    FILTER_TYPE_BANDSTOP,
    FILTER_TYPE_ALLPASS,
};

enum FilterID {
    FILTER_ID_BIQUAD_I,
    FILTER_ID_BIQUAD_II,
    FILTER_ID_BUTTERWORTH_I,
    FILTER_ID_BUTTERWORTH_II,
    FILTER_ID_ONEPOLE,
};

struct Filter;

typedef struct {
    const struct Filter *filter;
    void *private_context;
    enum FilterType type;
    int cascaded;
    double cutoff;
    double cutoff2;
    double samplerate;
    int taps;
} FilterContext;

int a52_filter_init(FilterContext *f, enum FilterID id);

void a52_filter_run(FilterContext *f, double *out, double *in, int n);

void a52_filter_close(FilterContext *f);

#endif /* FILTER_H */
